<?php


namespace app\common\model;


use think\Model;

class TradeChild extends Model
{
    public function getListPage($current_page=1,$num=10){
        $count = $this->where('status','<>','99')->count();
        $total = ceil($count/$num);
        $res = $this->where('status','<>','99')->limit(($current_page-1)*$num,$num)->select();
        $pageInfo = [
            "current_page"=>$current_page,
            "total"=>$total
        ];
        $result = [
            'pageInfo' =>$pageInfo,
            'list' => $res
        ];
        return $result;
    }

    public function addTradeChild($date){
        $result = $this->save($date);
        return $result;
    }
    public function getTradeChildById($where){
        $result = $this->where($where)->find();
        return $result;
    }
    public function getTradeChildByWhere($where){
        $result = $this->where($where)->select();
        return $result;
    }
    public function updateTradeChild($id,$data){
        $result = $this->where($id)->save($data);
        return $result;
    }
    public function removeTradeChild($id){
        $where = [
            'id'=>$id
        ];
        $result = $this->where($where)->delete();
        return $result;
    }
}